﻿using UnityEngine;
using UnityEngine.UI;

namespace DiverseStudents.Scripts
{
    internal class ListEmpetDragScript : MonoBehaviour
    {
        GameObject emptyDrag;

        public void UpdateSize(float width, float height)
        {
            emptyDrag = new GameObject("Mod_DragNull", typeof(Button),typeof(Image), typeof(CanvasGroup),typeof(LayoutElement));
            emptyDrag.SetActive(false);
            emptyDrag.GetComponent<Image>().type = Image.Type.Sliced;
            emptyDrag.transform.SetParent(transform, false);
            emptyDrag.AddComponent<ListItemDragScript>();
            var rt = emptyDrag.transform as RectTransform;
            rt.sizeDelta = new Vector2(width, height);
            var cg =  emptyDrag.GetComponent<CanvasGroup>();
            cg.alpha = 0;
            cg.blocksRaycasts = false;
            cg.interactable = false;
        }


        public void SetEmptyIndex(int index)
        {
            emptyDrag.transform.SetSiblingIndex(index);
        }

        public void ShowEmpty()
        {
            emptyDrag.SetActive(true);
        }

        public void HideEmpty()
        {
            emptyDrag.SetActive(false);
        }

    }
}
